import Vue from "vue";
import VueRouter from "vue-router";
// 导入vue-router
import Article from "@/views/Article.vue";
import Collect from "@/views/Collect.vue";
import User from "@/views/User.vue";
import Like from "@/views/Like.vue";
import Layout from "@/views/Layout.vue";
import Detail from "@/views/Detail.vue";
import ZuiXin from "@/views/ZuiXin.vue";
import Tuijian from "@/views/TuiJian.vue";
import Login from "@/views/Login.vue";
import Register from "@/views/Register.vue";

Vue.use(VueRouter);
// 创建路由对象
const router = new VueRouter({
  // 改类名
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
  routes: [
    {
      path: "/",
      redirect: "/login",
    },

    // {
    //   path: "/article",
    //   component: Article,
    // },
    // {
    //   path: "/collect",
    //   component: Collect,
    // },
    // {
    //   path: "/like",
    //   component: Like,
    // },
    // {
    //   path: "/user",
    //   component: User,
    // },
    // 外层切换 父路由 只要处理详情页面(一级路由)
    {
      path: "/detail/:id",
      component: Detail,
    },
    {
      path: "/login",
      component: Login,
    },
    {
      path: "/register",
      component: Register,
    },
    // 将来用来放置子路由出口 +4个导航
    {
      path: "/layout",
      component: Layout,
      children: [
        {
          path: "/",
          redirect: "/layout/article",
        },
        {
          path: "/layout/article",
          component: Article,
          children: [
            {
              path: "/layout/article/zuixin",
              component: ZuiXin,
            },
            {
              path: "/layout/article/tuijian",
              component: Tuijian,
            },
          ],
        },
        {
          path: "/layout/collect",
          component: Collect,
        },
        {
          path: "/layout/like",
          component: Like,
        },
        {
          path: "/layout/user",
          component: User,
        },
      ],
    },
  ],
});
export default router;
